package com.shanzmoo.h5.domain.vo;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.shanzmoo.db.mall.entity.vo.MallOrderDetailVO;
import com.shanzmoo.db.order.entity.dto.MallOrderRedisDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 商城订单信息
 * @author Gzhao 2020/12/25
 */
@Data
@ApiModel("商城订单信息")
public class MallOrderVO implements Serializable {

    private static final long serialVersionUID = 1758L;

    @ApiModelProperty(name = "订单号")
    private String orderNo;

    @ApiModelProperty(name = "订单状态：0-待支付 1-待发货 2-已发货 9-已关闭")
    private Integer status;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(name = "下单时间")
    private LocalDateTime createTime;

    @ApiModelProperty(name = "收货人")
    private String contacts;

    @ApiModelProperty(name = "联系方式")
    private String mobile;

    @ApiModelProperty(name = "收货地址")
    private String reciveAddress;

    @ApiModelProperty(name = "物流公司")
    private String logisticsType;

    @ApiModelProperty(name = "物流单号")
    private String logisticsNo;

    @ApiModelProperty(name = "商品总金额")
    private BigDecimal goodsAmount;

    @ApiModelProperty(name = "优惠券金额")
    private BigDecimal couponAmount;

    @ApiModelProperty(name = "运费")
    private BigDecimal freight;

    @ApiModelProperty(name = "实付金额")
    private BigDecimal receiveAmount;

    @ApiModelProperty(name = "发票类型：0-普通电子发票")
    private Integer invoiceType;

    @ApiModelProperty(name = "发票抬头", example = "XXXXXX")
    private String invoiceTitle;

    @ApiModelProperty(name = "发票内容：0-购物明细，1-数据电子，2-3c类型", example = "2")
    private Integer invoiceContentType;

    @ApiModelProperty(name = "商城订单商品明细")
    private List<MallOrderDetailVO> orderDetailList;

    public static MallOrderVO create(MallOrderRedisDTO orderRedisDTO) {
        MallOrderVO orderVO = JSON.parseObject(JSON.toJSONString(orderRedisDTO), MallOrderVO.class);
        orderVO.setReciveAddress(orderRedisDTO.getDistrictStr() + " " + orderRedisDTO.getAddress());

        return orderVO;
    }
}
